//import authService from '@/services/auth.service';
const auth={
    state: {
        token: null,
        loginState: false,
        userInfo: null,
      },
      mutations: {
        loginMutation: (state) => {
          state.loginState = true;
        },
        logoutMutation: (state) => {
          state.loginState = false;
        },
        SET_TOKEN: (state, token) => {
          state.token = token;
        },
        SET_USER: (state, user) => {
          state.userInfo = user;
        }
      },
      actions: {
        userInfoAction: async ({ commit }, userInfo) => {
          if (userInfo) {
            commit("userInfoMutation", userInfo);
          }
        },
        loginAction: async ({ commit }, userInfo) => {
          // authService.login(userInfo).then((result)=>{
          //   if(result && result.code ==='200' && result.data){
          //     commit("loginMutation", true);
          //   }else{
          //     commit("loginMutation", true);
          //   }
          // });
          console.log(userInfo)
          if(userInfo.username=='admin'&&userInfo.password=='1'){
            commit("loginMutation", true);
          }else{
            commit("logoutMutation", true);
          }
        },
      },
      getters: {
        token: state => state.token? state.token: 'N/A',
        loginState: state => state.loginState? state.loginState: 'false',
        userInfo: state => state.userInfo? state.weatherInfo.userInfo : '{}'
    }
}
export default auth
